Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use adafruit_ticks.ticks_ms for scrolling_label animation #208

Merged
merged 6 commits into from
Jun 24, 2024

Conversation

RetiredWizard
Copy link
Contributor

As described in adafruit/circuitpython#5411 time.monotonic loses precision over time, which eventually causes the scrolling_label animation to occur every time an update method is called. This can result in the scrolling text suddenly speeding up dramatically.

This PR uses supervisor.ticks_ms and adds a bit of logic to watch for the value rolling over instead of time.monotonic() which should resolve the issue. As mentioned by Dan in the referenced issue, another option would be to use time.monotonic_ns and similarly watch for the rollover, however apparently not all boards support the monotonic_ns method.

@RetiredWizard
Copy link
Contributor Author

The CI didn't like including supervisor. I don't know if that can be fixed in the requirements/toml/??? files somewhere or if it's a bigger issue with the approach.

@FoamyGuy
Copy link
Contributor

I think the step that is failing is the docs build. If you add "supervisor" to the list here:

autodoc_mock_imports = ["displayio", "adafruit_bitmap_font", "fontio", "bitmaptools"]
it should be able to complete successfully I think.

@RetiredWizard
Copy link
Contributor Author

think the step that is failing is the docs build. If you add "supervisor" to the list here:

That did the trick 😁 Thanks!

Copy link
Contributor

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned by Dan in the referenced issue, another option would be to use time.monotonic_ns and similarly watch for the rollover, however apparently not all boards support the monotonic_ns method.

A small number of SAMD21 ("M0") boards support displayio, but don't support longints and therefore don't support monotonic_ns.

One issue is that supervisor.ticks_ms is not implemented by Blinka, which would make this not usable if used under Blinka.

I think the solution is to use https://github.com/adafruit/Adafruit_CircuitPython_ticks instead of using supervisor.ticks_ms() directly. The adafruit_ticks library chooses the ticks mechanism based on what is available.

@RetiredWizard RetiredWizard requested a review from dhalbert June 23, 2024 22:28
@RetiredWizard RetiredWizard changed the title Use supervisor.ticks_ms for scrolling_label animation Use adafruit_ticks.ticks_ms for scrolling_label animation Jun 23, 2024
Copy link
Contributor

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@dhalbert dhalbert merged commit 5353178 into adafruit:main Jun 24, 2024
1 check passed
@RetiredWizard RetiredWizard deleted the monoprecision branch June 24, 2024 20:42
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jun 25, 2024
Updating https://github.com/adafruit/Adafruit_CircuitPython_DS248x to 1.0.1 from 1.0.0:
  > Update ds248x_simpletest.py

Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI to 8.4.0 from 8.3.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#209 from justmobilize/add-ap-info

Updating https://github.com/adafruit/Adafruit_CircuitPython_ConnectionManager to 3.1.1 from 3.1.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_ConnectionManager#21 from justmobilize/update-wiznet-version-check

Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Text to 3.1.2 from 3.1.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Text#208 from RetiredWizard/monoprecision

Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 4.1.1 from 4.0.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#195 from DJDevon3/main
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#194 from justmobilize/post-file-as-data

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Added the following libraries: Adafruit_CircuitPython_S35710, Adafruit_CircuitPython_HX711

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Updated download stats for the libraries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants